/**
 * Created by 李柏霖
 * 2020/11/10 21:08
 */

package cn.lbl.face.sr;

import java.util.Scanner;

/*



12345
344

0

abcde
ac

3
abc中包含ac，且abc是所有满足中最小的
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        String s;
        for (int i = 0; i < s1.length(); i++) {
            for (int j = i; j < s1.length(); j++) {
                s = s1.substring(i, j + 1);
                if (s.equals(s2)) {
                    System.out.println(s);
                }
//                System.out.println(s);
                for (int k = 0; k < s.length(); k++) {
                    for (int l = k; l < s.length(); l++) {
                        String sub=(""+s.charAt(k)+s.charAt(l));
                        if (sub.equals(s2)) {
                            System.out.println(l+1);
                            return;
                        }
                    }
                }
            }
        }

        System.out.println(0);
    }
}
